package com.wordsay.web.config;

import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.ext.handler.ContextPathHandler;
import com.jfinal.kit.PathKit;
import com.jfinal.render.ViewType;
import com.wordsay.context.Context;
import com.wordsay.web.context.WebContext;
import com.wordsay.web.controller.DataController;
import com.wordsay.web.controller.IndexController;

public class WebConfig extends JFinalConfig {

	@Override
	public void afterJFinalStart(){
		
		WebContext.isAnalysted = false;
		Context.setWordsayProperites(PathKit.getWebRootPath()+"/WEB-INF/config/wordsay.properties");
		
	}
	
	@Override
	public void configConstant(Constants constants) {
		// TODO Auto-generated method stub
		constants.setDevMode(true);
		constants.setViewType(ViewType.VELOCITY);
	}

	@Override
	public void configHandler(Handlers handlers) {
		// TODO Auto-generated method stub
		handlers.add(new ContextPathHandler("base"));//得到工程路径

	}

	@Override
	public void configInterceptor(Interceptors interceptors) {
		// TODO Auto-generated method stub

	}

	@Override
	public void configPlugin(Plugins plugins) {
		// TODO Auto-generated method stub

	}

	@Override
	public void configRoute(Routes routes) {
		// TODO Auto-generated method stub
		routes.add("/",IndexController.class);
		routes.add("/data",DataController.class);
	}

}
